package com.lins.storedisk.controller;

import com.lins.storedisk.bo.FileBo;
import com.lins.storedisk.entity.FileEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author linshuo
 * @Date 2023/12/8 16:11
 */

@Slf4j
//@SaIgnore
@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    FileBo fileBo;

    @GetMapping("/suggest")
    public List<String> getSuggestions(String keyword) {
        // 模拟从数据库中获取相关搜索建议的过程
        List<String> suggestions = new ArrayList<>();

        List<FileEntity> list = fileBo.searchLike(keyword);
        list.forEach(f -> suggestions.add(f.getUrl()));

        return suggestions;
    }


}
